﻿using System.IO;
using System.Text;
using System.Net;
using System.Xml;

using ECCIT;

namespace ECCIT.Net.SAML2.Protocols
{
    public class Extensions
    {
        // Fields
        private XmlNodeList data;

        // Methods
        public Extensions()
        {
        }

        public Extensions(XmlElement xmlElement)
        {
            if (!IsValid(xmlElement))
            {
                throw new SerializationException("The XML is not an Extensions.");
            }
            this.data = xmlElement.ChildNodes;
        }

        public Extensions(XmlNodeList data)
        {
            this.data = data;
        }

        public static bool IsValid(XmlElement xmlElement)
        {
            return (xmlElement.LocalName.Equals("Extensions") && xmlElement.NamespaceURI.Equals("urn:oasis:names:tc:SAML:2.0:protocol"));
        }

        public XmlElement ToXml(XmlDocument xmlDocument)
        {
            XmlElement element = xmlDocument.CreateElement("samlp", "Extensions", "urn:oasis:names:tc:SAML:2.0:protocol");
            if (this.data != null)
            {
                foreach (XmlElement element2 in this.data)
                {
                    element.AppendChild(element.OwnerDocument.ImportNode(element2, true));
                }
            }
            return element;
        }

        // Properties
        public XmlNodeList Data
        {
            get
            {
                return this.data;
            }
            set
            {
                this.data = value;
            }
        }
    }
}
